//
//  UILabel+CountDown.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/12.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "UILabel+CountDown.h"

@implementation UILabel (CountDown)

- (void)setupCountDownTitle:(NSString *)title height:(CGFloat)height{
    
    self.font = XJFONTSET_R(14);
    self.textColor = WHITE_COLOR;
    self.text = title;
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = height/2;
    self.backgroundColor = XJCOLOR_RGBA(0, 0, 0, 0.4);
    self.textAlignment = NSTextAlignmentCenter;
    //添加图片
    NSMutableAttributedString * countDownAttri = [[NSMutableAttributedString alloc]initWithString:title];
    NSTextAttachment *attch = [[NSTextAttachment alloc] init];
    attch.image = [UIImage imageNamed:@"Count down"];
    attch.bounds = CGRectMake(0, 0, 10, 10);
    NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attch];
    [countDownAttri insertAttributedString:string atIndex:0];
    self.attributedText = countDownAttri;
}

@end
